Kenexa     Kenexa XML Integrations                                                     

 

 

 

Source Code to post the XML to the Kenexa Integration URL in C#

 

Parameters

URL = Kenexa provided Post URL

Input XML = XML being submitted

 

public string HTTPPostIntegrations(string URL, string InputXML)

        {

            string strXML = "";

            sCode = "405"; sShortDescription = ""; sLongDescription = "";

            try

            {

                string iLoadUrl = URL;

                System.Net.WebRequest webRequest = System.Net.WebRequest.Create(iLoadUrl);

                webRequest.Method = "POST";

                webRequest.ContentType = "text/xml";

 

                StreamWriter strWriter = new StreamWriter(webRequest.GetRequestStream(), Encoding.UTF8);

                strWriter.WriteLine(InputXML);

                strWriter.Close();

 

                System.Net.WebResponse webResponse = webRequest.GetResponse();

                Stream stream = webResponse.GetResponseStream();

 

                StreamReader strRead = new StreamReader(stream, Encoding.UTF8);

                strXML = strRead.ReadToEnd();

 

                XmlDocument xmlDoc = new XmlDocument();

                xmlDoc.LoadXml(strXML);

                string Success = xmlDoc.SelectSingleNode("//Code").InnerText;

 

                sShortDescription = xmlDoc.SelectSingleNode("//PacketInfo/Status/ShortDescription").InnerText;

                sLongDescription = xmlDoc.SelectSingleNode("//PacketInfo/Status/LongDescription").InnerText;

 

                if (Success == "200")

                {

                    sCode = "200";

                }

            }

            catch (Exception ex)

            {

                sShortDescription = ex.Source;

                sLongDescription = ex.ToString();

            }

 

            return strXML;

        }

 

 

 

© 2008 Kenexa